//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _RANDOMDOUBLEWIDGET_H
#define _RANDOMDOUBLEWIDGET_H
//
#include <QWidget>
#include <model/randomdouble.h>
//
class QComboBox;
class QGridLayout;
class QLabel;
class QLineEdit;
class QVBoxLayout;
class RandomDoubleWidget:public QWidget
{
   Q_OBJECT
   Q_DISABLE_COPY(RandomDoubleWidget)
//construction
public:
   RandomDoubleWidget(QWidget *p_parent=0);
   RandomDoubleWidget(model::RandomDouble p_value,QWidget *p_parent=0);
//signals
signals:
   void value_changed();
//value
public:
   model::RandomDouble get_value() const;
   void set_value(model::RandomDouble p_value);
   bool is_null_value() const;
   void set_null_value(bool p_null_value);
//implementation
protected slots:
   void on_type_currentIndexChanged(int p_i);
   void on_constant_editingFinished();
   void on_interval_min_editingFinished();
   void on_interval_max_editingFinished();
private:
   model::RandomDouble value;
   bool null_value;
   QVBoxLayout *top_layout;
   QComboBox *type_combo;
   QLineEdit *constant_edit;
   QGridLayout *interval_top_layout;
   QLabel *interval_min_label;
   QLineEdit *interval_min_edit;
   QLabel *interval_max_label;
   QLineEdit *interval_max_edit;
   QLabel *error_label;
   void construct();
   void update_type_combo();
   void setup_widget();
   void update_widget();
   void delete_widget();
   void setup_null_widget();
   void delete_null_widget();
   void setup_constant_widget();
   void delete_constant_widget();
   void update_constant_widget();
   void setup_interval_widget();
   void delete_interval_widget();
   void update_interval_widget();
   void setup_error_widget();
   void delete_error_widget();
};
//
#endif
